// Copyright (c) 2010
// by http://openlightgroup.net/

using System;
using System.Linq;
using DotNetNuke.Common;
using DotNetNuke.Entities.Users;
using DotNetNuke.Services.Exceptions;
using System.Collections.Generic;
using System.Web.UI.WebControls;
using System.IO;

namespace SilverlightDebateForum
{
    public partial class View : DotNetNuke.Entities.Modules.PortalModuleBase
    {
        public string SilverlightInitParams { get; set; }
        public string SilverlightSourceParams { get; set; }
        public string splashscreensource { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    // Set RIAKey
                    string strRIAKey = RIAAuthentication.SetRIAKey(UserId, this.Request.UserHostAddress);

                    // Register Silverlight.js file
                    Page.ClientScript.RegisterClientScriptInclude(this.GetType(), "SilverlightJS",
                        (this.TemplateSourceDirectory + "/Silverlight.js"));

                    SilverlightSourceParams = this.TemplateSourceDirectory + "/ClientBin/SilverlightDebate.xap";
                    splashscreensource = this.TemplateSourceDirectory + "/custompreloader.xaml";
                    SilverlightInitParams = string.Format("Username={0},UserId={1},RIAKey={2},PortalId={3},IPAddress={4}", UserInfo.DisplayName, UserId.ToString(), strRIAKey, PortalId.ToString(), this.Request.UserHostAddress);
                }
            }
            catch (Exception exc)
            {
                // Module failed to load
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
    }
}